<?php
/* @var $model object */

/* @var $project_name string */

use backend\models\form\FormProject;
use kartik\date\DatePicker;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\bootstrap\Modal;

?>
<style>


</style>
<div class="row">
    <div class="col-sm-12">
        <div class="panel panel-default panel-border-color panel-border-color-primary">
            <div class="panel-heading panel-heading-divider"><?= ($model->isNewRecord ? '新增项目' : "修改项目") . $project_name; ?></div>
            <div class="panel-body">
                <div class="project-form">

                    <?php $form = ActiveForm::begin([
                        'options' => [
                            'id' => 'project-form',
                            'enctype' => "multipart/form-data",
                        ],
                        'enableAjaxValidation' => true,
                        'validationUrl' => 'ajax-underway-validate',
                    ]); ?>

                    <?= $form->errorSummary($model, [
                        'header' => '<button class="close" data-dismiss="alert">×</button>',
                        'class' => 'alert alert-danger fade in'
                    ]) ?>

                    <?= Html::activeHiddenInput($model, 'parent_id'); ?>
                    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
                    <?= $form->field($model, 'is_achievement')->radioList(FormProject::$yes_no_dict) ?>
                    <?= $form->field($model, 'progress_status')->radioList(FormProject::$progress_status_dict) ?>

                    <?= $form->field($model, 'start_time')->widget(DatePicker::classname(), [
                        'options' => ['placeholder' => '', 'autocomplete' => 'off',],
                        'type' => 1,
                        'pluginOptions' => [
                            'autoclose' => true,
                            'todayHighlight' => true,
                            'format' => 'yyyy-mm-dd',
                            'minViewMode' => 0,
                        ],
                    ]) ?>
                    <?= $form->field($model, 'end_time')->widget(DatePicker::classname(), [
                        'options' => ['placeholder' => '', 'autocomplete' => 'off',],
                        'type' => 1,
                        'pluginOptions' => [
                            'autoclose' => true,
                            'todayHighlight' => true,
                            'format' => 'yyyy-mm-dd',
                            'minViewMode' => 0,
                        ],
                    ]) ?>
                    <?= $form->field($model, 'description')->textarea(['maxlength' => true]) ?>

                    <?= Html::activeHiddenInput($model, 'uuid') ?>

                    <div class="form-group btns">
                        <?= Html::submitButton('保存', ['class' => 'btn btn-primary']) ?>
                    </div>
                    <?php ActiveForm::end(); ?>
                </div>
            </div>
        </div>
    </div>
</div>

<?php
//创建modal
Modal::begin([
    'id' => 'modal',
    'header' => '<h4 class="modal-title"></h4>',
    //'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
    'size' => 'modal-lg',
    'options' => [
        //'data-backdrop'=>'static',//点击空白处不关闭弹窗
        //'data-keyboard'=>false,
    ],
]);
Modal::end();

$js = <<<JS
    /*jQuery('#project-form').yiiActiveForm("add", {
        "id": "project-members",
        "container": ".field-project-members",
        "input": "#project-members",
        "validate": function (attribute, value, messages, deferred, form) {
            yii.validation.required(value, messages, {"message": "负责人不能为空。"});
        }
    });
    jQuery('#project-form').yiiActiveForm("add", {
        "id": "project-year",
        "container": ".field-project-year",
        "input": "#project-year",
        "validate": function (attribute, value, messages, deferred, form) {
            yii.validation.required(value, messages, {"message": " 所属年份不能为空。"});
        }
    });*/
JS;
$this->registerJs($js);


?>
<script>

</script>
